// 引入动态路由
import { constantRoutes, asyncRoutes } from '@/router'
const state = {
  routes: []
}
const mutations = {
  setroutes(state, data) {
    // 合并静态路由，动态路由
    state.routes = [...constantRoutes, ...data]
  }
}
const actions = {
  filtersRoutes(store, data) {
    // data是传过来的权限列表menu
    // console.log(data)
    const routes = asyncRoutes.filter(item => data.indexOf(item.name) !== -1)
    // console.log(routes)
    // 修改路由，筛选后的路由
    store.commit('setroutes', routes)
    return routes
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
